package org.domeos.framework.api.service;

import org.domeos.framework.api.controller.exception.PermitException;
import org.domeos.framework.api.model.auth.User;
import org.domeos.global.CurrentThreadInfo;

/**
 * Created by yangyu-ds on 2016/5/30.
 */
public abstract class BaseService {
    protected User getLoginUser() {
        User user = CurrentThreadInfo.getUser();
        if (user == null) {
            throw new PermitException("no user logged in");
        }
        return user;
    }

    protected void checkUserIsLogin() {
        User user = CurrentThreadInfo.getUser();
        if (user == null) {
            throw new PermitException("no user logged in");
        }
    }
}
